package com.esp.studentManagementSystem.repository;

import com.esp.studentManagementSystem.pojo.po.entity.ID.RoleUserId;
import com.esp.studentManagementSystem.pojo.po.entity.Student;
import com.esp.studentManagementSystem.pojo.po.entity.SysRoleUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysRoleUserRepository extends JpaRepository<Student, Long> {
    /**
     * 查询所有角色权限对应关系
     */
    @Query("SELECT ru FROM SysRoleUser ru")
    List<SysRoleUser> findAllRoleUser();

    /**
     * 根据uid和rid复合主键查询角色权限对应关系
     */
    @Query("SELECT ru FROM SysRoleUser ru WHERE ru.id = ?1")
    SysRoleUser findRoleUserByUidAndRid(RoleUserId id);
}
